package com.tvunetworks.center.device.model.param;

import com.tvunetworks.center.common.constant.LocalConstant;
import lombok.Data;
import lombok.experimental.Accessors;
import org.apache.commons.lang.StringUtils;

/**
 * @author Etan Yang
 * @create: 2021/11/12 15:24
 */

@Data
@Accessors(chain = true)
public class UpdateSlugParam {
    private String id;
    private String sourceId;
    private String slug;
    private String sourceName;
    private String externalId;
    private Long    endTime;
    /**
     * source 类型
     * Pack = 1,
     * Grid = 100,
     * GLink = 101,
     * Ext = 200,
     * YouTube = 201,
     * LocalSDI = 300,
     * Rtil = 400,
     * Html = 500
     */
    private Integer sourceType;

    /**
     * 获取传给tvuSearch服务的sourceType
     * @param sourceType 字符串
     */
    public void setSourceType(String sourceType) {
        if (StringUtils.isEmpty(sourceType)) {
            return;
        }
        switch (sourceType.toLowerCase()) {
            case LocalConstant.DeviceType.T:
                this.sourceType = 1;
                break;
            case LocalConstant.DeviceType.X:
                this.sourceType = 100;
                break;
            case LocalConstant.DeviceType.G_LINK:
                this.sourceType = 101;
                break;
            case LocalConstant.DeviceType.Ext:
                this.sourceType = 200;
                break;
            case LocalConstant.DeviceType.LOCAL_SDI:
                this.sourceType = 300;
                break;
            case "YouTube":
                this.sourceType = 201;
                break;
            case "Rtil":
                this.sourceType = 400;
                break;
            case "Html":
                this.sourceType = 500;
                break;
            default:
                this.sourceType = null;
        }
    }
}
